<?php
	$publicPath[]   = PHOTOBOOK_DIR . '/' . $this->album->album_dir . '/' . 'thumb.jpg';
	$publicPath[]   = PHOTOBOOK_DIR . '/' . $this->album->album_dir . '/' . 'thumb.gif';
	$publicPath[]   = PHOTOBOOK_DIR . '/' . $this->album->album_dir . '/' . 'thumb.png';
	$thumbPath      = $publicPath[0];
	$realPath       = $this->docRoot . '/' . $thumbPath;

	foreach($publicPath as $p){
		$realPath = $this->docRoot . '/' . $p;
		if(file_exists($realPath)){
			$thumbPath = $p;
		}
	}

	$sale		  = 'nonsale-album';
	if($this->album->Event['is_sale']){
		$sale    = 'sale-album';
		$href    = $this->url(array('category' => 'download', 'keyword' => $this->album->slug), 'portfolio-search');
	}else{
		$href    = $this->url(array('album'=> $this->album->slug, 'useThumb' => 0), 'portfolio-album-preview');
	}

/* 	if(!file_exists(dirname($realPath))){
		mkdir(dirname($realPath), true, 0755);
	}*/
?>
	<a class="album-thumb <?php echo $sale; ?> rounded" href="<?php echo $href; ?>" title="<?php echo $this->album->title; ?> - Photobbok Album">
			<span class="bg-thumbnail toprnd" style="background:url('/<?php echo $thumbPath; ?>') no-repeat bottom center"></span>
			<span class="desc">
				<?php echo $this->escape($this->album->title); ?><br />
				<?php echo $this->escape($this->album->Event['location']); ?>
			</span>
	</a>

